﻿using System.ServiceModel;

using Coding4Fun.Cannon.Wcf.Properties;

namespace Coding4Fun.Cannon.Wcf
{
	// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "SettingsService" in both code and config file together.
	[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
	public class SettingsService : ISettingsService
	{
		#region cameras

		public string GetTwitterUserName()
		{
			return Settings.Default.TwitterUserName;
		}

		public string GetTwitterPassword()
		{
			return Settings.Default.TwitterPassword;
		}

		public string GetOverheadCameraUri()
		{
			return Settings.Default.OverheadCamera;
		}

		//public void SetOverheadCameraUri(string uri)
		//{
		//    Settings.Default.OverheadCamera = uri;
		//    Settings.Default.Save();
		//}

		public string GetDriveCameraUri()
		{
			return Settings.Default.OnboardCamera;
		}

		//public void SetDriveCameraUri(string uri)
		//{
		//    Settings.Default.OnboardCamera = uri;
		//    Settings.Default.Save();
		//}
		#endregion
		#region Aiming Settings
		public double GetAimPanVelocity()
		{
			return Settings.Default.AimPanVelocity;
		}

		public double GetAimFiringTiltAngle()
		{
			return Settings.Default.AimFiringTiltAngle;
		}

		//public void SetAimPanVelocity(double velocity)
		//{
		//    Settings.Default.AimPanVelocity = velocity;
		//    Settings.Default.Save();

		//    (new AimService()).SetPanVelocity(velocity);
		//}

		public double GetAimTiltVelocity()
		{
			return Settings.Default.AimTiltVelocity;
		}

		//public void SetAimTiltVelocity(double velocity)
		//{
		//    Settings.Default.AimTiltVelocity = velocity;
		//    Settings.Default.Save();

		//    (new AimService()).SetTiltVelocity(velocity);
		//}

		public double GetAimPanMinAngle()
		{
			return Settings.Default.AimPanMinAngle;
		}

		public double GetAimPanMaxAngle()
		{
			return Settings.Default.AimPanMaxAngle;
		}

		//public void SetAimPanMinAndMaxAngles(double minAngle, double maxAngle)
		//{
		//    Settings.Default.AimPanMinAngle = minAngle;
		//    Settings.Default.AimPanMaxAngle = maxAngle;
		//    Settings.Default.Save();

		//    (new AimService()).SetPanMinAndMaxAngles(minAngle, maxAngle);
		//}

		public double GetAimTiltMinAngle()
		{
			return Settings.Default.AimTiltMinAngle;
		}

		public double GetAimTiltMaxAngle()
		{
			return Settings.Default.AimTiltMaxAngle;
		}

		//public void SetAimTiltMinAndMaxAngles(double minAngle, double maxAngle)
		//{
		//    Settings.Default.AimTiltMinAngle = minAngle;
		//    Settings.Default.AimTiltMaxAngle = maxAngle;
		//    Settings.Default.Save();

		//    (new AimService()).SetTiltMinAndMaxAngles(minAngle, maxAngle);
		//}
		#endregion
		#region motor

		public int GetDriveMaxPowerLeftMotor()
		{
			return Settings.Default.DriveMaxPowerLeftMotor;
		}

		public int GetDriveMaxPowerRightMotor()
		{
			return Settings.Default.DriveMaxPowerRightMotor;
		}

		//public void SetDriveMaxPower(int power)
		//{
		//    Settings.Default.DriveMaxPowerLeftMotor =
		//        Settings.Default.DriveMaxPowerRightMotor = power;
		//    Settings.Default.Save();

		//    (new DriveService()).SetDriveMaxPower(power);
		//}

		//public void SetDriveMaxPowerByMotor(int leftPower, int rightPower)
		//{
		//    Settings.Default.DriveMaxPowerLeftMotor = leftPower;
		//    Settings.Default.DriveMaxPowerRightMotor = rightPower;
		//    Settings.Default.Save();

		//    (new DriveService()).SetDriveMaxPowerByMotor(leftPower, rightPower);
		//}

		public string GetDriveComport()
		{
			return Settings.Default.MotorControlSerialPort;
		}

		//public void SetDriveComport(string value)
		//{
		//    Settings.Default.MotorControlSerialPort = value;
		//    Settings.Default.Save();
		//}
		
		#endregion
	}
}
